package com.zl.smartmall.library.vo;

import java.util.List;

import net.tsz.afinal.FinalDb;
import android.content.Context;

import com.zl.smartmall.library.account.IAuth;
import com.zl.smartmall.library.po.GZCommunityInfo;

public class GZCommunityInfoDAO {
	
	public static synchronized void saveAll(Context cxt,List<GZCommunityInfo> list){
		FinalDb db = FinalDb.create(cxt);
		db.batchSave(list);
	}
	
	public static synchronized void DeleteAll(Context cxt){
		FinalDb db = FinalDb.create(cxt);
		db.deleteByWhere(GZCommunityInfo.class,"currentId="+IAuth.getInstance().loadUserInfo().getUid());
	}
	
	public static synchronized void delete(Context cxt,GZCommunityInfo info){
		FinalDb db = FinalDb.create(cxt);
		db.deleteByWhere(GZCommunityInfo.class, "currentId="+IAuth.getInstance().loadUserInfo().getUid()+" and pid="+info.getPid());
	}
	
	public static synchronized List<GZCommunityInfo> getAll(Context cxt){
		FinalDb db = FinalDb.create(cxt);
		return db.findAllByWhere(GZCommunityInfo.class, "currentId="+IAuth.getInstance().loadUserInfo().getUid());
	}
	
	public static synchronized void updata(Context cxt,GZCommunityInfo info){
		FinalDb db = FinalDb.create(cxt);
		db.update(info, "currentId="+IAuth.getInstance().loadUserInfo().getUid()+" and pid="+info.getPid());
	}
}
